﻿@inject Microsoft.Extensions.Localization.IStringLocalizer<AddEditBrandModal> _localizer

<EditForm Model="@AddEditBrandModel" OnValidSubmit="SaveAsync">
    <FluentValidationValidator @ref="_fluentValidationValidator" />
    <MudDialog>
        <TitleContent>
            @{
                if (AddEditBrandModel.Id == 0)
                {
                    <MudText Typo="Typo.h6">
                        <MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-3 mb-n1" />
                        @_localizer["Add Brand"]
                    </MudText>
                }
                else
                {
                    <MudText Typo="Typo.h6">
                        <MudIcon Icon="@Icons.Material.Filled.Update" Class="mr-3 mb-n1" />
                        @_localizer["Update Brand"]
                    </MudText>
                }
            }
        </TitleContent>
        <DialogContent>
            <MudGrid>
                @if (AddEditBrandModel.Id != 0)
                {
                    <MudItem xs="12" md="6">
                        <MudTextField Disabled For="@(() => AddEditBrandModel.Id)" @bind-Value="AddEditBrandModel.Id" Label="@_localizer["Id"]" />
                    </MudItem>
                }
                <MudItem xs="12" md="6">
                    <MudTextField T="string" For="@(() => AddEditBrandModel.Name)" @bind-Value="AddEditBrandModel.Name" Label="@_localizer["Name"]" />
                </MudItem>
                <MudItem xs="12" md="6">
                    <MudTextField For="@(() => AddEditBrandModel.Description)" @bind-Value="AddEditBrandModel.Description" Label="@_localizer["Description"]" />
                </MudItem>
                <MudItem xs="12" md="6">
                    <MudTextField For="@(() => AddEditBrandModel.Tax)" @bind-Value="AddEditBrandModel.Tax" Label="@_localizer["Tax"]" />
                </MudItem>
            </MudGrid>
        </DialogContent>
        <DialogActions>
            <MudButton DisableElevation Variant="Variant.Filled" OnClick="Cancel">@_localizer["Cancel"]</MudButton>
            @if (AddEditBrandModel.Id != 0)
            {
                <MudButton DisableElevation Variant="Variant.Filled" ButtonType="ButtonType.Submit" Disabled="@(!Validated)" Color="Color.Secondary">@_localizer["Update"]</MudButton>
            }
            else
            {
                <MudButton DisableElevation Variant="Variant.Filled" ButtonType="ButtonType.Submit" Disabled="@(!Validated)" Color="Color.Success">@_localizer["Save"]</MudButton>
            }
        </DialogActions>
    </MudDialog>
</EditForm>